package com.slz3.business.module.goodsManagement.gooGoods.steward;

import com.slz3.business.frame.util.VE;
import com.slz3.business.module.goodsManagement.gooGoods.domain.GooGoods;
import com.slz3.business.module.goodsManagement.gooGoods.enums.GoodsIsactiveEnum;

import java.math.BigDecimal;

public class GooGoodsSteward {

    public static void redundancy(GooGoods gooGoods) {
        if (gooGoods.getSerGoodsIsactive() != null) {
            if (GoodsIsactiveEnum.isCash(gooGoods.getSerGoodsIsactive())) {
                // 现价 - 现金商品
                if (VE.isNotEmptyArr(gooGoods.getSerGoodsPrice(), gooGoods.getSerGoodsDazhe())) {
                    gooGoods.setSerGoodsPricel(gooGoods.getSerGoodsPrice().multiply(
                            new BigDecimal(gooGoods.getSerGoodsDazhe()).divide(new BigDecimal(100))
                    ));
                }
            } else if (GoodsIsactiveEnum.isPoints(gooGoods.getSerGoodsIsactive())) {
                // 现价 - 积分商品
                if (VE.isNotEmptyArr(gooGoods.getSerGoodsJifenNum(), gooGoods.getSerGoodsDazhe())) {
                    gooGoods.setSerGoodsPricel(new BigDecimal(gooGoods.getSerGoodsJifenNum()).multiply(
                            new BigDecimal(gooGoods.getSerGoodsDazhe()).divide(new BigDecimal(100))
                    ));
                }
            }
        }
    }
}
